import java.util.Scanner;

/**
 * 放苹果
 */
public class ApplePosition {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int appleNum = scanner.nextInt();
            int plateNum = scanner.nextInt();
            System.out.println(countNum(appleNum, plateNum));
        }
    }

    private static int countNum(int appleNum, int plateNum) {
        if (appleNum == 0 || plateNum == 1) {
            return 1;
        } else if (appleNum < plateNum) {
            return countNum(appleNum, appleNum);
        } else {
            return countNum(appleNum, plateNum-1) + countNum(appleNum-plateNum, plateNum);
        }
    }
}
